import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author wonghiu
 * @Date 2021/8/31 20:36
 * @Version 1.0.1
 */
public class ppd {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Position[] node = new Position[505];
        String[] str = new String[505];
        for (int i = 0; i < n; i++) {
            str[i] = sc.next();
            node[i].smin = str[i];
            node[i].s = str[i];
            node[i].id = i;
            int len = str[i].length();
            for (int j = 0; j < len / 2; j++) {
                if (str[i].charAt(j)>str[i].charAt(len-j-1)){
//                    swap(node[i].smin.charAt(j),node[i].smin.charAt(len-j-1));
                    char temp = node[i].smin.charAt(j);

                    char[] chars = node[i].smin.toCharArray();
                    chars[j] = node[i].smin.charAt(len-j-1);
                    node[i].smin = Arrays.toString(chars);


                }
            }
        }
    }

    class Position{
        int id;
        String smin;
        String s;
    }
}
